package com.bjpowernode.web.controller;

import com.bjpowernode.api.vo.IncomeInfo;
import com.bjpowernode.web.views.ResultView;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @description:
 * @author: panDeng_Zhu
 * @time: 2022/11/19 12:56
 */

@Slf4j
@Api(tags = "收益接口")
@RestController
public class IncomeController extends BaseController {


    //查询用户最近收益记录
    @ApiOperation(value = "查询收益记录",notes = "查询客户的收益记录，分页")
    @GetMapping("/v1/income/info")
    public ResultView incomeMoreInfo(@RequestHeader("userId") Integer userId,
                                     @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNo,
                                     @RequestParam(value = "pageSize", required = false, defaultValue = "6") Integer pageSize) {
        ResultView<IncomeInfo> result = ResultView.FAIL();
        if (userId > 0) {
            List<IncomeInfo> incomeInfoList = incomeService.queryIncomeInfoByUserId(userId, pageNo, pageSize);
            result = ResultView.SUCCESS();
            result.setList(incomeInfoList);
        }
        return result;
    }
}
